Keep all Uses in a single vector#172
Draft
Amanieu wants to merge 1 commit intobytecodealliance:mainfrom
Draft
Conversation
Previously, each live range would carry a list of uses in a `SmallVec<[Use; 4]>`, which was an inefficient use of memory. This PR instead keeps a single `Vec<Use>` for all uses in a function, sorted by vreg and position. Each live range now holds a `Range<u32>` of indices which refer to its uses inside this vector. Benchmarks show that this consistently improves compilation times by ~2%.
Amanieu
commented
Dec 6, 2023
Comment on lines
-828
to
+836
| if u.operand.constraint() == OperandConstraint::Any { | ||
| trace!(" -> migrating this any-constrained use to the spill range"); | ||
| spill_uses.push(u); | ||
| // if u.operand.constraint() == OperandConstraint::Any { | ||
| // trace!(" -> migrating this any-constrained use to the spill range"); | ||
| // spill_uses.push(u); | ||
|
|
||
| // Remember if we're moving the def of this vreg into the spill range, so that | ||
| // we can set the appropriate flags on it later. | ||
| spill_starts_def = spill_starts_def || is_def; | ||
| // // Remember if we're moving the def of this vreg into the spill range, so that | ||
| // // we can set the appropriate flags on it later. | ||
| // spill_starts_def = spill_starts_def || is_def; | ||
|
|
||
| continue; | ||
| } | ||
| // continue; | ||
| // } |
Contributor
Author
There was a problem hiding this comment.
This is the only part that I couldn't make work out of the box: since each live range can only refer to a single continuous range of uses, disjoint sets of uses cannot be represented by a single live range.
One option would be to create multiple sub-ranges for the spill bundle here, so that Any uses can still be transferred to the spill bundle.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, each live range would carry a list of uses in a
SmallVec<[Use; 4]>, which was an inefficient use of memory.This PR instead keeps a single
Vec<Use>for all uses in a function, sorted by vreg and position. Each live range now holds aRange<u32>of indices which refer to its uses inside this vector.Benchmarks show that this consistently improves compilation times by ~2%.